<%@page import="org.swim.remote.exceptions.SwimException.Severity"%>
<%@page import="org.swim.web.servlet.consts.ErrorHandling"%>
<%@page import="org.swim.remote.exceptions.SwimException"%>
<%@page import="org.swim.web.servlet.consts.*"%>
<%@page import="java.lang.Exception"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%
	Severity severity = (Severity) request
			.getAttribute(ErrorHandling.SERVER_EXCEPTION_SEVERITY);

	if (severity != null) {
		if (severity == Severity.ERROR
				|| severity == Severity.FATAL_ERROR
				|| severity == Severity.WARNING) {
			String servlet = (String) request
					.getAttribute(ErrorHandling.SERVLET);
			Exception e = (Exception) request
					.getAttribute(ErrorHandling.SERVER_EXCEPTION);
			Action a = (Action) request
					.getAttribute(ErrorHandling.SERVLET_ACTION);
			String title;
			if (severity == Severity.WARNING)
				title = "Warning!";
			else if (severity == Severity.ERROR)
				title = "Error!";
			else
				title = "Fatal error!";

			String message = "We feel sorry but Swim server has found an error.";
%>
<style>
.modal-body-error {
	background-color: #F2DEDE;
	color: #B94A48;
}

.modal-header-error {
	color: #B94A48;
}
</style>
<!-- Start Error Modal -->
<div id="errorHandling" class="modal hide fade" tabindex="-1"
	role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-header modal-header-error">
		<h3 id="myModalLabel"><%=title%></h3>
	</div>
	<div class="modal-body modal-body-error">
		<p><%=message%></p>
		<p>
			<small><b><i>System details</i></b><br /> Servlet: <b><%=servlet%></b><br />
				Action: <%=a.name()%><br /> <b><%=e.getClass().getSimpleName()%></b>
				details: <%=e.getMessage()%></small>
		</p>
	</div>
	<div class="modal-footer modal-footer-error">
		<button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Close</button>
	</div>
</div>
<!-- End Error Modal -->
<%
	}
	}
%>